import { GameServerCluster } from "./shared/gateClient/GameServer";
import path from "path";
import { getConfig, startWatchConfig } from "./shared/gameCluster/gfConfigMgr";
import { RedisConfig } from "./shared/gameCluster/redisHelper";

var gateConfigPath = path.resolve(__dirname, '../gf.gate.config.json');
export interface GfGateConfig {
    /**配置所有可以连接的集群 */
    gameServerCfgList: GameServerCluster[];
    /**认证模块链接的redis配置 */
    authRedisConfig:RedisConfig;
}

/**开始监控gate服务器配置,并返回获取到的配置对象 */
export function startWatchGateConfig():GfGateConfig{
    var ret = startWatchConfig(gateConfigPath);
    if (!ret.succ) {
        console.error(ret.err);
    }
    return ret.data as GfGateConfig;
}

export function getGateConfig(): GfGateConfig {
    var ret = getConfig(gateConfigPath);
    if (!ret.succ) {
        console.error(ret.err);
    }
    return ret.data as GfGateConfig;
}